package com.electromagnetic.industry.software.manage.mapper;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.electromagnetic.industry.software.manage.pojo.models.EdFileInfo;
import com.electromagnetic.industry.software.manage.pojo.other.FileInfoVO;
import com.electromagnetic.industry.software.manage.pojo.req.FileInfoQueryDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface EdFileInfoMapper extends BaseMapper<EdFileInfo> {


    default EdFileInfo selectById(String id) {
        return this.selectOne(Wrappers.lambdaQuery(EdFileInfo.class)
                .select(EdFileInfo.class, file -> !StrUtil.equals(file.getColumn(), "file_content"))
                .eq(EdFileInfo::getId, id));
    }

    default EdFileInfo selectById1(String id) {
        return this.selectOne(Wrappers.lambdaQuery(EdFileInfo.class)
                .eq(EdFileInfo::getId, id));
    }

    @Select("select max(id) from ed_file_info where length(id) = 6")
    String maxPrjId();

    /**
     * 收藏页 数据查询
     *
     * @param page
     * @param ids
     * @param queryDTO
     * @return
     */
    IPage<FileInfoVO> queryFileList(Page<FileInfoVO> page,
                                    @Param("ids") List<String> ids,
                                    @Param("pars") FileInfoQueryDTO queryDTO,
                                    @Param("saveStatus") int saveStatus,
                                    @Param("effectFlag") int effectFlag);
}
